Repository navigation
Feat/1.3.0 animators - #6
Merged
Merged
Conversation
Cumulative distances, pointAt/headingAt/slice by distance, and nearest() to project a position onto the route, optionally within a window around a known distance so a route that passes twice through a place is not confused.
VehicleTracker puts GPS positions on the route. It searches a window around the last known distance first, then the whole route, and reports positions farther than the tolerance as off route without losing the progress.
A move can carry a RouteTarget. The marker then moves by distance along the route, so it turns at corners and takes its rotation from the route, and a move that starts mid-way (latestOnly) continues from the distance it is at.
A tracked vehicle has a route. Each position is put on the route (searching a window around the last known distance first), the marker moves to it, and the route is drawn as the part travelled and the part remaining, following the marker as it is shown. followRoute makes the marker take the route between two positions, consumeRoute and the two RouteStyle values control how it is drawn, and onOffRoute reports positions beyond the tolerance. updateMarkers and updatePolylines leave the marker and the lines of a tracked vehicle alone.
MapAnimationController.polylineAnimation(id) returns a handle with pause(), resume(), seek(progress), value, a progress stream, onComplete and onCycle. To make pause and seek possible the polyline animation now always runs on its own simulation (the same timing as AnimationController.repeat, with or without a count) that can start from any point in time. onComplete is not called for animations that repeat forever, and the streams are closed on dispose.
PolylineCodec.decode/encode read and write the Google Encoded Polyline format (precision 5 or 6), checked against the example of the documentation. boundsOf gives the box that contains a list of points and replaces the _getBounds helper of the example app.
PolylineAnimator.animateAll returns every polyline for a frame (by default the one from animate). The controller draws all of them in one call to the map, removes the ones an animation stops drawing, and keeps them out of the set the app manages: updatePolylines does not remove them and removing or replacing the animated polyline takes its extras away too.
PulseAnimator draws a dimmed copy of the route with a lighter, wider glow (ID <id>#glow) that travels along it, measured in distance. DashFlowAnimator simulates moving dashes by cutting the start of the line, and loops by moving a whole number of dash and gap per cycle. Its limitation (the pattern is in pixels, the cut in meters) and that it is unchecked on devices is documented.
Every RouteSegment (a fraction of the route by distance, with a color) is a polyline of its own with the ID <id>#<n>. The animator, if any, is applied to the whole route as if it were one line: it decides which part is visible and how opaque, and that part is split among the segments, sharing the points where they meet. An animation without duration is now drawn at once, and redrawn when its polyline changes, which static segmented routes need.
followCamera(CameraFollow) moves the camera after a marker (zoom, tilt, and the map turned with the vehicle or north up), at most about 10 times per second, sending the last position when the marker stops. stopFollowingCamera ends it. The package does not receive map gestures by itself: the app passes onCameraMoveStarted to GoogleMap and, when the camera had been quiet, the following stops and CameraFollow.onFollowStopped is called. The movement a camera update of ours causes is ignored for a moment. How each platform reports it has not been checked on devices, and this is documented.
pauseInBackground (default true): polyline animations stop when the app goes to the background and go on from the same place when it comes back; an animation paused through its handle stays paused. Marker moves are not paused because they must show the latest positions. respectReduceMotion (default true): when the system asks to reduce motion (disableAnimations), polylines are drawn as they are, with PolylineAnimator.reducedMotionFrame deciding what that means for animations made of several polylines, and markers and vehicles go to their new position at once.
Animators table, the DashFlowAnimator limitation, colors by section, the camera that follows (and why the app has to pass onCameraMoveStarted), background pausing and reduced motion. Adds tests for RouteStyle and RouteSegment.
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.